package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;


/**
 * @Classname: ReflectDemo10
 * @Author: bromide
 * @CreateTime: 2022/4/19--14:41
 * @Version: V1.0
 * @Description: 在反射机制中获取注解的参数
 */
public class ReflectDemo10 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        //拿到所有方法
        Method[] methods = cls.getDeclaredMethods();
        for (Method method : methods) {
            if (method.isAnnotationPresent(AutoRunMethod.class)) {
                AutoRunMethod arm = method.getAnnotation(AutoRunMethod.class);
                int value = arm.value();
                System.out.println("方法" + method.getName() + "上@AutoRunMethod注解指定的参数是:" + value);
            }
        }
    }
}
